package com.etc.serviceImpl;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.etc.dao.BlogMapper;
import com.etc.dao.LogMapper;
import com.etc.entity.Blog;
import com.etc.entity.Log;
import com.etc.service.BlogService;

/**
*	@author: zmf  
*	@date: 2018年11月8日 下午5:15:15 
*/
@Service
public class BlogServiceImpl implements BlogService{
	@Resource
	private BlogMapper blogMapper;
	@Resource
	private LogMapper logMapper;

	@Override	
	public Blog getBlogById(int blogId) {
		// TODO Auto-generated method stub
		
		return blogMapper.selectByPrimaryKey(blogId);
	}
	
	//@Transactional(propagation=Propagation.REQUIRED,isolation=Isolation.DEFAULT)
	public boolean insert(Blog blog) {		
		int n1=blogMapper.insert(blog);		
		//System.out.println(1/0);
		Log log=new Log();
		log.setLogOp("addBlog");
		log.setLogDate(new Date().toLocaleString());
		int n2=	logMapper.insert(log);
		return n1>0 && n2>0;
		
	}

}
